package com.qf.micrograss.grass.controller;

import com.qf.common.core.common.R;
import com.qf.common.core.page.PageParam;
import com.qf.common.core.page.PageVO;
import com.qf.micrograss.grass.param.GrassAddParam;
import com.qf.micrograss.grass.service.GrassService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * --- 缘分让我们相遇乱世以外 ---
 *
 * @author SJY
 * 2025/1/4
 */
@RestController
@RequestMapping("/article")
public class GrassController {
    @Resource
    private GrassService grassService;

    @PostMapping("/upload/img")
    public R uploadImg(MultipartFile file) {
        Object path = grassService.uploadImg(file);
        return R.ok(path);
    }

    @PostMapping("/add")
    public R addGrass(@RequestBody GrassAddParam param) {
        grassService.addGrass(param);
        return R.ok();
    }

    @GetMapping("/page")
    public R grassPage(PageParam param) {
        PageVO pageVO = grassService.grassPage(param);
        return R.ok(pageVO);
    }
}
